<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <!-- Default box -->
            <div class="card card-primary card-outline">
                <div class="card-body">
                    <form role="form" id="quickForm" method="post" action="">
                        <input type="hidden" name="id" value="{{.model.Id}}">
                        <div class="card-body">
                            <div class="form-group row">
                                <label for="nickname" class="col-sm-2 col-form-label">昵称</label>
                                <div class="col-sm-10">
                                    <input type="text" readonly name="nickname" class="form-control-plaintext" id="nickname"
                                           placeholder="" value="{{.model.Nickname}}">
                                </div>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="form-group row">
                                <label for="account" class="col-sm-2 col-form-label">账号</label>
                                <div class="col-sm-10">
                                    <input type="text" readonly name="account" class="form-control-plaintext" id="account"
                                           placeholder="" value="{{.model.Account}}">
                                </div>
                            </div>
                        </div>
                        <div class="card-body">
                            <div clas="form-group row">
                                <label for="role" class="col-sm-2 col-form-label">角色s</label>
                                <div class="col-sm-10">
                                    <input type="text" readonly name="account" class="form-control-plaintext" id="account"
                                           placeholder="" value="{{.model.Account}}">
                                </div>
                            </div>
                        </div>
                        <!-- /.card-body -->
                        <div class="card-footer" style="text-align: center">
                            <button type="submit" class="btn btn-primary">提交</button>
                            <a href="/admin/admin/index" class="btn btn-danger">返回</a>
                        </div>
                    </form>
                </div>
                <!-- /.card-body -->
            </div>
        </div>
        <!-- /.card -->
    </div>
</div>
<script type="text/javascript">
    let url = "";
    let id = '{{.model.Id}}';
    url = "/admin/api/admin/change-password";

    $(document).ready(function () {
        $.validator.setDefaults({
            submitHandler: function (form) {
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: "json",
                    data: $(form).serialize(),
                    beforeSend: function () {

                    },
                    success: function (res) {
                        if (res.code === 1) {
                            Swal.fire(
                                {
                                    icon: 'success',
                                    title: '提示！',
                                    text: '操作成功:)',
                                    showConfirmButton: false,
                                    timer: 1500,
                                    timerProgressBar: true,
                                }
                            ).then((r) => {
                                window.location.href = '/admin/admin/index'
                            });
                        } else {
                            alert(res.message)
                        }
                    },
                    error: function (e) {
                        let res = JSON.parse(e.responseText);
                        Swal.fire(
                            {
                                icon: 'error',
                                title: '提示！',
                                text: res.message,
                                showConfirmButton: false,
                                timer: 1500,
                                timerProgressBar: true,
                            }
                        )
                    }
                })
            }
        });
        $('#quickForm').validate({
            rules: {
                name: {
                    required: true,
                },
            },
            messages: {
                // name: {
                //     // required: "请输入分类名称",
                // }
            },
            errorElement: 'span',
            errorPlacement: function (error, element) {
                error.addClass('invalid-feedback');
                element.closest('.form-group').append(error);
            },
            highlight: function (element, errorClass, validClass) {
                $(element).addClass('is-invalid');
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).removeClass('is-invalid');
            }
        });
    });
</script>